//
//  JKLoginViewController.m
//  VistorDemo
//
//  Created by Jack on 2021/8/6.
//

#import "JKLoginViewController.h"
#import "JKUserManager.h"

@interface JKLoginViewController ()
@property (weak, nonatomic) IBOutlet UITextField *userNameField;
@end

@implementation JKLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (IBAction)cancleAction:(id)sender {
    
    if (self.loginCallback) {
        self.loginCallback(NO);
    }
    [self dismissViewControllerAnimated:YES completion:NULL];
    
}

- (IBAction)loginAction:(id)sender {
    
    if (self.userNameField.text.length > 0) {
        
        JKUser *user = [[JKUser alloc] init];
        user.userName = self.userNameField.text;
        [[JKUserManager sharedUserManager] login:user];
        
        if (self.loginCallback) {
            self.loginCallback(YES);
        }
    }else{
        if (self.loginCallback) {
            self.loginCallback(NO);
        }
    }
    [self dismissViewControllerAnimated:YES completion:NULL];
    
}

- (void)dealloc{
    NSLog(@"login dealloc");
}

@end
